<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring核心技术：IoC与AOP深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        .code-block pre {
            margin: 0;
            padding: 1.5rem;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        .first-letter {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, transparent);
            margin: 3rem 0;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            margin: 1.5rem 0;
            font-weight: 500;
        }
        .concept-card {
            background: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 10px 30px rgba(0,0,0,0.05);
            border-top: 4px solid #667eea;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-fadeInUp">
                Spring核心技术深度解析
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90 animate-fadeInUp" style="animation-delay: 0.2s;">
                掌握IoC与AOP，构建优雅的企业级应用
            </p>
            <div class="flex justify-center space-x-8 animate-fadeInUp" style="animation-delay: 0.4s;">
                <div class="text-center">
                    <i class="fas fa-cube text-4xl mb-2"></i>
                    <p class="text-lg">控制反转</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-layer-group text-4xl mb-2"></i>
                    <p class="text-lg">面向切面</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-cogs text-4xl mb-2"></i>
                    <p class="text-lg">动态代理</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Core Concepts Overview -->
        <section class="mb-16">
            <div class="grid md:grid-cols-2 gap-8">
                <div class="concept-card card-hover">
                    <h2 class="text-2xl font-bold mb-4 text-gradient">
                        <i class="fas fa-sync-alt mr-2"></i>控制反转（IoC）
                    </h2>
                    <p class="text-gray-700 leading-relaxed">
                        <span class="first-letter">S</span>pring使用控制反转的原则，通过依赖注入来管理和组装应用程序的各个组件。它将对象的创建和依赖关系的管理交给Spring容器，使得对象之间的解耦和配置更加灵活。
                    </p>
                </div>
                <div class="concept-card card-hover">
                    <h2 class="text-2xl font-bold mb-4 text-gradient">
                        <i class="fas fa-cut mr-2"></i>面向切面编程（AOP）
                    </h2>
                    <p class="text-gray-700 leading-relaxed">
                        <span class="first-letter">S</span>pring通过AOP机制提供了横切关注点的处理能力。它通过在程序运行时动态地将通用的横切逻辑（例如事务管理、安全性检查、日志记录等）织入到应用程序的关注点中，实现了关注点的分离和模块化。
                    </p>
                </div>
            </div>
        </section>

        <!-- IoC Section -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="text-gradient">IoC 控制反转</span>
            </h2>
            
            <div class="bg-white rounded-lg shadow-lg p-8 mb-8">
                <h3 class="text-2xl font-semibold mb-4">
                    <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>核心概念
                </h3>
                <p class="text-gray-700 leading-relaxed text-lg">
                    控制反转是将对象的创建权限转交给IoC容器。之前都是自己创建、管理对象的生命周期，现在都交给IoC容器来统一完成。以后需要对象时直接找IoC容器获取。
                </p>
                <div class="highlight-box">
                    <i class="fas fa-info-circle mr-2"></i>
                    传统方式：User user = new User(); → IoC方式：由容器管理对象生命周期
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                    <h4 class="text-xl font-semibold mb-4">
                        <i class="fas fa-code text-blue-500 mr-2"></i>常用注解
                    </h4>
                    <ul class="space-y-2">
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Controller</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@RestController</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Service</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Repository</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Component</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Configuration</li>
                        <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i>@Bean</li>
                    </ul>
                </div>
                <div class="bg-white rounded-lg shadow-lg p-6 card-hover">
                    <h4 class="text-xl font-semibold mb-4">
                        <i class="fas fa-plug text-purple-500 mr-2"></i>依赖注入（DI）
                    </h4>
                    <p class="text-gray-700 mb-4">
                        DI思想主要解决bean之间的依赖关系。例如Controller中需要注入Service。
                    </p>
                    <ul class="space-y-2">
                        <li class="flex items-center"><i class="fas fa-arrow-right text-purple-500 mr-2"></i>@Autowired 自动装配</li>
                        <li class="flex items-center"><i class="fas fa-arrow-right text-purple-500 mr-2"></i>@Resource 资源注入</li>
                        <li class="flex items-center"><i class="fas fa-arrow-right text-purple-500 mr-2"></i>构造器注入</li>
                    </ul>
                </div>
            </div>

            <div class="bg-gray-100 rounded-lg p-6">
                <h4 class="text-xl font-semibold mb-3">
                    <i class="fas fa-microchip text-indigo-600 mr-2"></i>底层实现
                </h4>
                <p class="text-gray-700">
                    IoC的底层实现都是通过<span class="font-bold text-indigo-600">反射技术</span>来实现的，Spring容器在运行时动态创建和管理对象。
                </p>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- AOP Section -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="text-gradient">AOP 面向切面编程</span>
            </h2>

            <div class="bg-white rounded-lg shadow-lg p-8 mb-8">
                <h3 class="text-2xl font-semibold mb-4">
                    <i class="fas fa-magic text-purple-500 mr-2"></i>核心概念
                </h3>
                <p class="text-gray-700 leading-relaxed text-lg mb-4">
                    AOP是面向切面编程，能够动态地在某个方法之前或之后执行特定操作。
                </p>
                <div class="grid md:grid-cols-3 gap-4">
                    <div class="bg-purple-50 p-4 rounded-lg text-center">
                        <i class="fas fa-unlink text-3xl text-purple-600 mb-2"></i>
                        <p class="font-semibold">解耦</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg text-center">
                        <i class="fas fa-layer-group text-3xl text-purple-600 mb-2"></i>
                        <p class="font-semibold">核心业务与系统服务分离</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg text-center">
                        <i class="fas fa-bullseye text-3xl text-purple-600 mb-2"></i>
                        <p class="font-semibold">专注核心业务逻辑</p>
                    </div>
                </div>
            </div>

            <!-- AOP Visualization -->
            <div class="bg-white rounded-lg shadow-lg p-8 mb-8">
                <h4 class="text-xl font-semibold mb-4 text-center">AOP工作原理图</h4>
                <div class="mermaid">
                    graph LR
                        A[客户端] --> B[代理对象]
                        B --> C[前置通知]
                        C --> D[目标方法]
                        D --> E[后置通知]
                        E --> F[返回结果]
                        B -.-> G[异常通知]
                        B -.-> H[环绕通知]
                        style A fill:#f9f,stroke:#333,stroke-width:2px
                        style B fill:#bbf,stroke:#333,stroke-width:2px
                        style D fill:#bfb,stroke:#333,stroke-width:2px
                </div>
            </div>

            <!-- AOP通知类型 -->
            <div class="bg-white rounded-lg shadow-lg p-8 mb-8">
                <h4 class="text-xl font-semibold mb-6">
                    <i class="fas fa-bell text-orange-500 mr-2"></i>AOP通知类型
                </h4>
                <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h5 class="font-semibold text-blue-600">前置通知</h5>
                        <p class="text-sm text-gray-600">目标方法之前调用，控制不了目标方法是否调用</p>
                    </div>
                    <div class="border-l-4 border-green-500 pl-4">
                        <h5 class="font-semibold text-green-600">后置通知</h